function input_hint() {
    // placeholder text
    $('[placeholder]').focus(function () {
        var input = $(this);
        if (input.val() == input.attr('placeholder')) {
            input.val('');
            input.removeClass('placeholder');
        }
    }).blur(function () {
        var input = $(this);
        if (input.val() == '' || input.val() == input.attr('placeholder')) {
            input.addClass('placeholder');
            input.val(input.attr('placeholder'));
        }
    }).blur();
    $('[placeholder]').parents('form').submit(function () {
        $(this).find('[placeholder]').each(function () {
            var input = $(this);
            if (input.val() == input.attr('placeholder')) {
                input.val('');
            }
        })
    });

}

function focussearch() {$('#s').focus(); }

$(document).ready(function () {


    $('a[rel*=facebox]').facebox({
        loadingImage: '/wp-content/themes/uicloud/js/facebox/loading.gif',
        closeImage: '/wp-content/themes/uicloud/js/facebox/closelabel.png'
    })

    input_hint();

    // Animated Scroll
    $('a[href*=#]').click(function () {
        if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '')
        && location.hostname == this.hostname) {
            var $target = $(this.hash);
            $target = $target.length && $target
          || $('[name=' + this.hash.slice(1) + ']');
            if ($target.length) {
                var targetOffset = $target.offset().top - 30;
                $('html,body')
            .animate({ scrollTop: targetOffset }, 750);
                return false;
            }
        }
    });



    $('#slideshow').cycle({
        fx: 'scrollHorz',
        speed: '125',
        timeout: 0,
        prev: '.arrow-left',
        next: '.arrow-right',
        pager: '#itemnav',
        pagerAnchorBuilder: function (idx, slide) {
            // return sel string for existing anchor
            return '#itemnav li:eq(' + (idx) + ') a';
        }
    });

    if ($('#slideshow').children().length <= 1) {
        $('.arrow-left').hide();
        $('.arrow-right').hide();
        $('#itemnav').hide();
    }

    $('#btn_edit_tags').click(function () {
        $(this).hide();
        $('#current_tags').hide();
        $('#btn_save_tags').show();
        $('#btn_cancel').show();
        $('#edit_tags').show();
        $('#edit_tags textarea').focus();
    });
    $('#btn_cancel').click(function () {
        $(this).hide();
        $('#current_tags').show();
        $('#btn_edit_tags').show();
        $('#btn_save_tags').hide();        
        $('#edit_tags').hide();        
    });

    $('.note i').click(function () {
        $(this).parent().fadeOut('fast');
    });

    $('.form-section input[type="text"], .form-section textarea').focus(function () {
        $(this).next().fadeIn('fast');
    }).blur(function () {
        $(this).next().fadeOut('fast');
    });

    $('.wpcf7-form-control-wrap input[type="text"], .wpcf7-form-control-wrap textarea').focus(function () {
        $(this).parents('.form-section').children('.hint').fadeIn('fast');
    }).blur(function () {
        $(this).parents('.form-section').children('.hint').fadeOut('fast');
    });
});

